<#include "../public/header.html">
    <div id="editdlg">
    </div>
        <div id="tb" style="padding:5px 5px; border-bottom: dashed #d2d2d2 1px;margin-bottom: 5px;">
            
        </div>
        <table id="list" class="easyui-datagrid" title="自动回复" style="width:100%;height:100%"
               sortName="id"
               sortOrder="asc"
               rownumbers="true"
               pagination="true"
               pagesize="50"
               singleSelect="true"
               data-options="url:'admin/WXReply/listJson',toolbar:toolbar">
            <thead>
            <tr>
                <th field="id" width="80" sortable="true">ID</th>
                <th field="reply_type" width="80" align="right" sortable="true">回复类型</th>
                <th field="key_word" width="100" align="right" sortable="true">关键词</th>
                <th field="msg_type" width="80" align="right" sortable="true">消息类型</th>
                <th field="content" width="150" align="right" sortable="true">内容</th>
            </tr>
            </thead>
        </table>

    <script type="text/javascript">
        var id ;
        $(function(){
            $("#tb").prependTo(".datagrid-toolbar");
        })
        var toolbar = [{
            id:70101,
            disabled:"${((permission_button.p70101!) == 'true')? string('','true')}",
            text:'添加',
            iconCls:'icon-add',
            handler:function(){

                $("#editdlg").dialog({
                    title:"添加",
                    iconCls: 'icon-edit',
                    width: 650,
                    height: 450,
                    closed: false,
                    cache: false,
                    modal: true,
                    href:"admin/WXReply/edit",
                    onLoad:function() {
                        $.messager.progress('close');
                    },
                    buttons: [{
                        text: '取消',
                        iconCls:'icon-cancel',
                        handler: function () {
                            $('#editForm').form('clear');
                            $("#editdlg").dialog("close");
                        }
                    },{
                        text: '保存',
                        iconCls: 'icon-ok',
                        handler: function () {
                            $('#editForm').form('submit',{
                                url:"admin/WXReply/save",
                                dataType:"json",
                                onSubmit:function(){
                                    return $(this).form('enableValidation').form('validate');
                                },
                                success:function(data){
                                    var data = eval('(' + data + ')');  // change the JSON string to javascript object

                                    alert(data.msg);
                                    $("#editdlg").dialog("close");
                                    $("#list").datagrid("reload");
                                }
                            });
                        }
                    }]
                });
            }
        },{
            id:70102,
            disabled:"${((permission_button.p70102!) == 'true')? string('','true')}",
            text:'编缉',
            iconCls:'icon-edit',
            handler:function(){
                var note =  $("#list").datagrid("getSelected");
                if(note == null){
                    $.messager.show({
                        title:'提醒',
                        msg:'请选择要编缉的行',
                        showType:'fade',
                        style:{
                            right:'',
                            bottom:''
                        }
                    });
                    return;
                }

                $.messager.progress({
                    text:'数据加载中....',
                    interval:100
                });

               $("#editdlg").dialog({
                   title:"编缉",
                   iconCls: 'icon-edit',
                   width: 650,
                   height: 450,
                   closed: false,
                   cache: false,
                   modal: true,
                   href:"admin/WXReply/edit?id="+note.id,
                   onLoad:function() {
                       $.messager.progress('close');
                   },
                   buttons: [{
                       text: '取消',
                       iconCls:'icon-cancel',
                       handler: function () {
                           $('#editForm').form('clear');
                           $("#editdlg").dialog("close");
                       }
                   },{
                       text: '保存',
                       iconCls: 'icon-ok',
                       handler: function () {
                           $('#editForm').form('submit',{
                               url:"admin/WXSetting/save",
                               onSubmit:function(){
                                   return $(this).form('enableValidation').form('validate');
                               },
                               success:function(data){
                                   var data = eval('(' + data + ')');  // change the JSON string to javascript object
                                   alert(data.msg);
                                   $("#editdlg").dialog("close");
                                   $("#list").datagrid("reload");
                               }
                           });
                       }
                   }]
               });
            }
        }];

        function search_but(){
           $("#list").datagrid("reload",{code:$("#code").val(),name:$("#name").val()});
        }

        function tree_select(note){
            $("#list").datagrid("reload",{code:$("#code").val(),name:$("#name").val(),dep_id:note.id});
        }
    </script>
    <#include "../public/footer.html">